package com.yuedou.api.service.product;

import com.yuedou.api.entity.mall.MallGroupOpenList;
import com.yuedou.api.entity.mall.MallGroupProduct;
import com.yuedou.api.entity.mer.Mer;
import com.yuedou.api.entity.product.ProductAttrValue;
import com.yuedou.api.entity.product.ProductCart;
import com.yuedou.api.entity.product.ProductOrder;
import com.yuedou.api.entity.product.ProductOrderInfo;
import com.yuedou.api.entity.wxuser.User;
import com.yuedou.api.entity.wxuser.UserAddress;
import com.yuedou.api.exception.TransactionalException;
import com.yuedou.api.service.base.BaseService;
import org.springframework.transaction.TransactionException;

import java.util.Date;
import java.util.List;

public interface ProductOrderService extends BaseService<ProductOrder> {

    /**
     *  订单的 添加
     * @param remark
     * @param
     * @return
     * @throws TransactionalException
     */
    String addNormalOrder(User user, UserAddress userAddress, Double allPrice, Integer order_type, String remark, String platform) throws TransactionalException;

    /**
     * 餐饮店的 订单的 新添加订单
     * @param user
     * @param allPrice
     * @param mer_id
     * @param table_id
     * @param user_count
     * @param remark
     * @param platform
     * @return
     * @throws TransactionalException
     */
    long addNormalMerNewOrder(User user, Double allPrice,int mer_id,int table_id, int user_count,String remark, String platform) throws TransactionalException;

    /**
     *  立即购买
     * @param user
     * @param userAddress
     * @param order_type
     * @param count
     * @param attrValue
     * @param remark
     * @return
     * @throws TransactionException
     */
    long buyNow(User user, UserAddress userAddress, int order_type, int count, ProductAttrValue attrValue, String remark, String platform) throws TransactionException;

    /**
     *  立即购买
     * @param user
     * @param userAddress
     * @param order_type
     * @param count
     * @param attrValue
     * @param remark
     * @return
     * @throws TransactionException
     */
    long buyNowBg(User user, UserAddress userAddress, int order_type, int count, ProductAttrValue attrValue, String remark, String platform) throws TransactionException;

    /**
     * 商家线下支付
     * @param user
     * @param order_type
     * @param mer
     * @param price
     * @param remark
     * @return
     * @throws TransactionException
     */
    long buyMerOffline(User user, int order_type, Mer mer, double price, String remark, String platform) throws TransactionException;

    /**
     * 根据  order_no  获取 订单信息
     * @param order_no
     * @return
     */
    ProductOrder getOrderByOrderNo(String order_no);

    /**
     *  未支付的 尾款总金额
     * @param order_id
     * @return
     */
    Double getOrderBalanceNoPay(Long order_id);

    /**
     *  已支付的 尾款总金额
     * @param order_id
     * @return
     */
    Double getOrderBalancePaid(Long order_id);

    /**
     * 更新订单的状态
     * @return
     */
    int updateOrderState(ProductOrder order, int state);

    /**
     * 根据订单状态获取订单数量
     * @param user_id
     * @param state
     * @return
     */
    int getOrderCountByState(Integer user_id, Integer state);

    int getOrderCountByTime(Integer seller_id, Integer state, Date begin_date, Date end_date);

    /**
     * 买家查订单
     * @param userId
     * @param state
     * @param pageIndex
     * @param pageSize
     * @return
     */
    List<ProductOrder> queryListByUserId(int userId, int order_type, int state, int pageIndex, int pageSize);

    /**
     * 商家查订单
     * @param merId
     * @param state
     * @param pageIndex
     * @param pageSize
     * @return
     */
    List<ProductOrder> queryListByMerId(int merId, int state, int pageIndex, int pageSize);

    /**
     *  普通订单的 支付完成操作
     */
    int buyNormalUpdate(ProductOrder order, User user);

    /**
     *  普通订单的 支付完成操作
     */
    int buyNormalOffline(ProductOrder order);

    /**
     *  订单详情
     * @param orderId
     * @return
     */
    ProductOrder getOrderDetail(long orderId);
}
